home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / DNA_XCMD / BASECOMP.C next >
Text File  |  1991-08-31  |  2KB  |  94 lines

  1. /*    BaseComp.c 
  2.     
  3.     Reece Hart
  4.     Molecular Genetics Laboratory, The Salk Institute
  5.     Division of Biology & Dept. of Comp. Sci, Washington University
  6.     America OnLine: Reece            Internet: reece@informatics.wustl.edu
  7.  
  8.     
  9.     Modification History
  10.     ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  11.     90 Nov 10    Original coding.
  12.     91 Aug 30    Augmented list of mapped codes to include keto/amino for
  13.                 completeness.
  14. */
  15.  
  16. #include    "BaseComp.h"
  17.  
  18. /*    ******************************************************************************
  19.     BaseCompliment()
  20.     
  21.     This function returns the complimentary base (type 'char') according to
  22.     Watson-Crick pairing (A - T, C - G), purine/pyrimidine pairing (A,G - C,T),
  23.     and amino/keto (A,C - G,T) pairing.
  24.         Watson-Crick:
  25.             A    ->    T        a    ->    t        adenine        ->    thymine
  26.             T    ->    A        t    ->    a        thymine        ->    adenine
  27.             C    ->    G        c    ->    g        cytosine    ->    guanine
  28.             G    ->    C        G    ->    c        guaning        ->    cytosine
  29.         Purine/Pyrimidine:    
  30.             R    ->    Y        r    ->    y        purine        ->    pyrimidine
  31.             Y    ->    R        y    ->    r        pyrimidine    ->    purine
  32.         Amino/Keto:
  33.             K    ->    M        k    ->    m        keto        ->    amino
  34.             M    ->    K        m    ->    k        amino        ->    keto
  35.     
  36.     All other values, including the IUPAC 'N' code for unknown bases, are
  37.     returned unchanged.
  38.     ******************************************************************************    */
  39.  
  40. char    BaseCompliment(char Base)
  41.     {
  42.     /*    A switch-case setup seemed to be the fastest, although less elegant
  43.         than other solutions                                                        */
  44.     switch (Base)
  45.         {
  46.         /*    Primary bases    */
  47.         case 'A':
  48.             return 'T';
  49.         case 'a':
  50.             return 't';
  51.             
  52.         case 'C':
  53.             return 'G';
  54.         case 'c':
  55.             return 'g';
  56.             
  57.         case 'G':
  58.             return 'C';
  59.         case 'g':
  60.             return 'c';
  61.             
  62.         case 'T':
  63.             return 'A';
  64.         case 't':
  65.             return 'a';
  66.  
  67.         /*    Purine/Pyrimidine pairing                                            */
  68.         case 'R':
  69.             return 'Y';
  70.         case 'r':
  71.             return 'y';
  72.  
  73.         case 'Y':
  74.             return 'R';
  75.         case 'y':
  76.             return 'r';
  77.         
  78.         /*    Amino/Keto pairing                                                    */    
  79.         case 'M':
  80.             return 'K';
  81.         case 'm':
  82.             return 'k';
  83.  
  84.         case 'K':
  85.             return 'M';
  86.         case 'k':
  87.             return 'm';
  88.         
  89.         /*    Undefined symbol╔ return it unmapped                                */
  90.         default:
  91.             return Base;
  92.         }
  93.     }
  94.